<template>
  <div class="myNews">
    <Card>
   <Row>
     <Col span="6">
       <Card title="我的消息" :padding="0" shadow style="width: 300px;">
         <CellGroup v-for="item in chatListData">

           <Cell :title=item.userT :to="{ name: 'news', params: { chatList: item}}" />

         </CellGroup>
       </Card>
     </Col>
     <Col span="18">
       <router-view></router-view>
     </Col>
   </Row>
    </Card>
  </div>
</template>

<script>
  import axios from "axios";

  export default {
    name: "myNews",
    data(){
      return{
        chatListData:[],
      }
    },
    methods:{
      getChat(){
        let userid = this.$getCookie("userId")
        axios.get("http://localhost:8888/chatController/queryAllById",{params: {userId:userid}}).then(res =>{
          this.chatListData = res.data;
          for (let i=0 ; i<res.data.length;i++){
            if (res.data[i].userT == '9999'){
              this.chatListData[i].userT = '任务助手'
            }else{
              this.chatListData[i].userT = '账单助手'
            }
          }
        })
      }
    },
    mounted() {
      this.getChat()
    }
  }
</script>

<style scoped>
  .myNews{
    margin:20px 0 0 20px;
  }
</style>
